import axios from 'axios';

const API_BASE_URL = '/api';

// 创建预订
export const createBooking = async (bookingData) => {
  try {
    const response = await axios.post(`${API_BASE_URL}/bookings`, bookingData);
    return response.data;
  } catch (error) {
    console.error('创建预订失败', error);
    throw error;
  }
};

// 获取我的预订
export const getMyBookings = async () => {
  try {
    const response = await axios.get(`${API_BASE_URL}/bookings/mine`);
    return response.data;
  } catch (error) {
    console.error('获取我的预订失败', error);
    throw error;
  }
};

// 取消预订
export const cancelBooking = async (bookingId) => {
  try {
    const response = await axios.post(`${API_BASE_URL}/bookings/${bookingId}/cancel`);
    return response.data;
  } catch (error) {
    console.error('取消预订失败', error);
    throw error;
  }
};  